<%@page import="org.springframework.ui.Model"%>
<%@page import="com.sofly.entity.Bom"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>bom管理</title>
</head>
<body>
	<!-- jQuery 主文件 -->
	<script type="text/javascript" src="../js/jquery.min.js" ></script>
	<!-- easyui 主文件 -->
	<script type="text/javascript" src="../js/jquery.easyui.min.js" ></script>
	<!-- 国际化文件 -->
	<script type="text/javascript" src="../js/locale/easyui-lang-zh_CN.js" ></script>
	<!-- easyui 主样式文件 -->
	<link rel="stylesheet" href="../js/themes/black/easyui.css" />
	<link rel="stylesheet" href="../js/themes/icon.css" />	
	<script type="text/javascript">
	   $(function(){
		    $("#tb").datagrid({
	   		url:"boms",
	   		method:"get",
			columns:[[  
			    {field:'Id',title:'全选',width:100,checkbox:true},      
				{field:'id',title:'序列号',width:100,align:'right'},    
				{field:'partnum',title:'零件编码',width:100,align:'right'},    
				{field:'desc',title:'描述',width:100,align:'right'},    
				{field:'size',title:'规格',width:100,align:'right'}, 
				{field:'weight',title:'重量',width:100,align:'right'},
				{field:'parent',title:'归属部件',width:100,align:'right'},
	    ]],
	    fit:true,
		toolbar:[{
			iconCls: 'icon-edit',
			text:"编辑",
			handler:function(){
				edit();
			}
		}
		,{
			iconCls: 'icon-add',
			text:"添加",
			handler:function(){
				add();
			}
		},
		{
			iconCls: 'icon-print',
			text:"打印",
			handler:function(){
				print();
			}
		}
		
		
		],
		onClickRow:function(index, row){
			alert(row.stockstandard);
		},
		onLoadSuccess:function(){//数据加载完毕之后触发事件..,想让数据端某列作为js按钮,就需要加载完数据后,给该列赋予easyui的类属性
			$("#btn_1").linkbutton({    
			    iconCls: 'icon-add'   
			});  
		},
		loadMsg:"数据加载中...，请等待!",
		singleSelect:true,
		fitColumns:true,
		pagination:true,
		rownumbers:true
	})
	
	function print(){
		var row = $('#tb').datagrid('getSelected');	
		if (row&&row.remark=="未下单"){
			if(confirm("确定下单？")){
			location="pdf?purchaseId="+row.purchaseId;
			$('#tb').datagrid('reload');
			}
		}else{
			alert("该产品已下单");
		}
		
	}
	   })
	</script>
	<style type="text/css">
		#fm{
			margin:0;
			padding:10px 30px;
		}
		.ftitle{
			font-size:14px;
			font-weight:bold;
			color:#666;
			padding:5px 0;
			margin-bottom:10px;
			border-bottom:1px solid #ccc;
		}
		.fitem{
			margin-bottom:5px;
		}
		.fitem label{
			display:inline-block;
			width:80px;
		}
	</style>
	</head>
	<body>
		<table id="tb" title="查看bom"></table>
	</body>
</html>